from django.shortcuts import render

# Create your views here.
from django.views import View

from contents.models import ContentCategory
from contents.utils import get_categories
from goods.models import GoodsChannelGroup


class IndexView(View):
    def get(self, request):
        data=get_categories()
        contents ={}
        categorys=ContentCategory.objects.all()
        for cat in categorys:
            contents[cat.key]=cat.content_set.filter(status=True).order_by('sequence')
            # print(contents[cat.key])
        context={
            'categories':data,
            'contents':contents,
        }
        # print(context)
        return render(request, 'index.html',context=context)